#pragma once
#include "../../../include/timer_interface.hpp"

class CP2P;
class CP2PSession;

class CTimer
{
public:
    virtual void OnTimer(void) = 0;

//    inline HTIMER get_timer(void){return m_timer;}
//    inline void set_timer(HTIMER timer){m_timer = timer;}
//
//    inline INT32 get_elapse(void){return m_elapse;}
//    inline INT32 get_count(void){return m_count;}
//protected:
//    HTIMER  m_timer;
//    INT32   m_elapse;
//    INT32   m_count;

    DEFMEMBER(HTIMER, m_timer, timer)
    DEFMEMBER(INT32, m_elapse, elapse)
    DEFMEMBER(INT32, m_count, count)
};

class CP2PTimerManager :
    public ITimerResponse
{
public:
    CP2PTimerManager(CP2P* p2p);
    virtual ~CP2PTimerManager(void);

    bool AddTimer(CTimer* timer, bool exact = false);
    bool ModTimer(CTimer* timer, bool exact = false);
    void DelTimer(CTimer* timer);

    virtual void OnTimer(HTIMER hTimer, void* pData);
protected:
    CP2P*   m_p2p;
};

class CHostCheck :
    public CTimer
{
public:
    CHostCheck(CP2P* p2p)
    {
        m_p2p = p2p;
        m_count = -1;
        m_elapse = 1000;
    }

    virtual void OnTimer(void);
protected:
    CP2P*   m_p2p;
private:
};
